package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 预约控制器
 */
@RestController
@RequestMapping("/mobile/order")
@Slf4j
public class MobileOrderController {

    @Autowired
    private OrderService orderService;

    /**
     * 体检预约
     * @param map
     * @return
     */
    @PostMapping("/submit")
    public Result addOrder(@RequestBody Map map) {
        return new Result(true, MessageConst.ORDER_SUCCESS, orderService.addOrder(map));
    }

    /**
     * 查询体检预约信息
     * @param id
     * @return
     */
    @GetMapping("/findById")
    public Result getOrderById(Integer id) {
        return new Result(true, MessageConst.QUERY_ORDER_SUCCESS, orderService.getOrderById(id));
    }
}
